import request from '@/config/axios'
import { update } from 'lodash-es'

// 产品图片 VO
// export interface ProdPictureVO {
//   id: number // id
//   prodId: number // 产品ID
//   name: string // 名称
//   fileId: number // 图片ID
//   remark: string // 备注
// }

export interface ProdPictureVO {
  name: string // 名称
  type: string  // 文件类型（修正拼写错误）
  updateMan: string // 上传人（使用后端期望的字段名）
  remark: string // 备注
  prodId: number // 产品ID（新增）
  fileId: number // 文件ID（新增）
  createTime: string // 创建时间
}

// 查询分页返回的产品图片 VO（对应后端 ProdPictureNewPageVO）
export interface ProdPictureNewPageVO {
  id: number
  pictureName: string
  pictureType: string
  pictureUrl?: string
  updateMan: string
  updateTime: string
}

// 产品图片 API
export const ProdPictureApi = {

  getProdPictureNewPage: async (params: any): Promise<{ list: ProdPictureNewPageVO[]; total: number }> => {
    return await request.get({ url: `/business/prod-picture/new-page`, params })
  },
  // 查询产品图片分页
  getProdPicturePage: async (params: any) => {
    return await request.get({ url: `/business/prod-picture/page`, params })
  },

  // 查询产品图片详情
  getProdPicture: async (id: number) => {
    return await request.get({ url: `/business/prod-picture/get?id=` + id })
  },

  // 新增产品图片
  createProdPicture: async (data: ProdPictureVO) => {
    return await request.post({ url: `/business/prod-picture/create`, data })
  },

  updatePricter:async(data:ProdPictureVO)=>{
    return await request.post({ url: `/business/prod-picture/updatePricter`, data })
  },
  

  // 修改产品图片
  updateProdPicture: async (data: ProdPictureVO) => {
    return await request.put({ url: `/business/prod-picture/update`, data })
  },

  // 删除产品图片
  deleteProdPicture: async (id: number) => {
    return await request.delete({ url: `/business/prod-picture/delete?id=` + id })
  },

  // 导出产品图片 Excel
  exportProdPicture: async (params) => {
    return await request.download({ url: `/business/prod-picture/export-excel`, params })
  },
}
